$(function () {
    var swiper = new Swiper('.swiper-container', {
        direction: 'vertical',
        hashnav: true,
        onInit: function (swiper) {
            if (swiper.realIndex === 0) ani_cls_set(0);
        },
        onSlideChangeStart: function (swiper) {
            $('img.arrow').fadeOut('1000').removeClass('arrow_go');
            ani_cls_reomove(swiper.previousIndex);
            if (swiper.realIndex === 5) $('img.arrow').css('display', 'none');
        },
        onSlideChangeEnd: function (swiper) {
            if (swiper.realIndex !== 5) $('img.arrow').addClass('arrow_go').fadeIn('2000');
            ani_cls_set(swiper.realIndex);
        }
    });
    var contentInfo = {
        node: $('.content .cirlce'),
        num: 4,
        src: ''
    }
    set_image(contentInfo);
    var introduceInfo = {
        node: $('.introduce .circle'),
        num: 3,
        src: ''
    }
    set_image(introduceInfo);
    var homesInfo = {
        node: $('.homes .circle'),
        num: 5,
        src: ''
    }
    set_image(homesInfo);
})
var nodes = {
    slide1: {
        center: $('.homes .center'),
        conten1: $('.homes .conten1'),
        fir2: $('.homes .fir2'),
        fir3: $('.homes .fir3'),
        conten2: $('.homes .conten2'),
        sec1: $('.homes .sec1'),
        sec2: $('.homes .sec2'),
        conten3: $('.homes .conten3'),
        thi1: $('.homes .thi1'),
        thi2: $('.homes .thi2'),
        conten4: $('.homes .conten4'),
        for1: $('.homes .for1'),
        conten5: $('.homes .conten5'),
        conff: $('.homes .conff')
    },
    quan: $('.discount img.quan_'),
    hand: $('.discount img.hand'),
    img1: $('.introduce .float img:nth-child(1)'),
    img2: $('.introduce .float img:nth-child(2)'),
    img3: $('.introduce .float img:nth-child(3)')
}

function ani_cls_set(index) {
    switch (index) {
        case 0:
            nodes['slide1'].center.addClass('center_go');
            nodes['slide1'].conten1.addClass('conf_go');
            nodes['slide1'].fir2.addClass('fir2_go');
            nodes['slide1'].fir3.addClass('fir3_go');
            nodes['slide1'].conten2.addClass('cons_go');
            nodes['slide1'].sec1.addClass('sec1_go');
            nodes['slide1'].sec2.addClass('sec2_go');
            nodes['slide1'].conten3.addClass('cont_go');
            nodes['slide1'].thi1.addClass('thi1_go');
            nodes['slide1'].thi2.addClass('thi2_go');
            nodes['slide1'].conten4.addClass('confo_go');
            nodes['slide1'].for1.addClass('for1_go');
            nodes['slide1'].conten5.addClass('conff_go');
            nodes['slide1'].conff.addClass('conff_go');
            break;
        case 1:

            break;
        case 2:
            nodes['quan'].addClass('quan_go');
            nodes['hand'].addClass('hang_go');
            break;
        case 3:
            break;
        case 4:
            nodes['img1'].addClass('img_1_go');
            nodes['img2'].addClass('img_2_go');
            nodes['img3'].addClass('img_3_go');
            break;
        case 5:

            break;
        default:
            break;
    }
}

function ani_cls_reomove(index) {
    switch (index) {
        case 0:
            nodes['slide1'].center.removeClass('center_go');
            nodes['slide1'].conten1.removeClass('conf_go');
            nodes['slide1'].fir2.removeClass('fir2_go');
            nodes['slide1'].fir3.removeClass('fir3_go');
            nodes['slide1'].conten2.removeClass('cons_go');
            nodes['slide1'].sec1.removeClass('sec1_go');
            nodes['slide1'].sec2.removeClass('sec2_go');
            nodes['slide1'].conten3.removeClass('cont_go');
            nodes['slide1'].thi1.removeClass('thi1_go');
            nodes['slide1'].thi2.removeClass('thi2_go');
            nodes['slide1'].conten4.removeClass('confo_go');
            nodes['slide1'].for1.removeClass('for1_go');
            nodes['slide1'].conten5.removeClass('conff_go');
            nodes['slide1'].conff.removeClass('conff_go');
            break;
        case 1:

            break;
        case 2:
            nodes['quan'].removeClass('quan_go');
            nodes['hand'].removeClass('hang_go');
            break;
        case 3:
            break;
        case 4:
            nodes['img1'].removeClass('img_1_go');
            nodes['img2'].removeClass('img_2_go');
            nodes['img3'].removeClass('img_3_go');
            break;
        case 5:

            break;
        default:
            break;
    }
}

function set_image(info) {
    var div = $('<div></div>');
    var num = info.num,
        node = info.node,
        src = info.src;
    for (; num > 0; num--) {
        var img = new Image();
        img.src = src
        div.append(img)
    }
    node.append(div.find('img').unwrap());
}